import Vue from 'vue'
import VueRouter from 'vue-router'

//启用vue-router功能
Vue.use(VueRouter);

//配置路由表
export default new VueRouter({
    //使用懒加载模式进行路由
    routes: [
        /* 主页 */
        { 
            path: "/home", 
            name: "Home",
            component: resolve => (require(["@/views/Home"], resolve)),
            /* 子组件 */
            children:[
                
            ]
        },
        /* 登录 */
        {
            path: "/",
            name: "Login",
            component: resolve => (require(["@/views/Login"], resolve))
        },
        /* 申请账号 */
        {
            path: "/reg",
            name: "Reg",
            component: resolve => (require(["@/views/Reg"], resolve))
        },
        /* 忘记密码 */
        {
            path: "/forget",
            name: "Forget",
            component: resolve => (require(["@/views/Forget"], resolve))
        },
    ]
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}